package com.xpresso.utils.rss;

import com.erclab.internal.xpresso.reports.Report;
import com.erclab.internal.xpresso.reports.ReportResultSet;

public class YahooMapsGeoRssWriter extends SimpleRssWriter {

	@Override
	public String createGeoRss(Report report) {
		StringBuffer xml = new StringBuffer();
		xml.append("<rss version=\"2.0\" xmlns:geo=\"http://www.w3.org/2003/01/geo/wgs84_pos#\" " +
			"xmlns:ymaps=\"http://api.maps.yahoo.com/Maps/V2/AnnotatedMaps.xsd\">");
		xml.append("<channel>" +
			"<title>" + report.getTitle() + "</title>" +
			"<description>" + report.getDescription() + "</description>");
		
		xml.append("<ymaps:Groups><Group><Title>xpresso</Title>"+
		      "<Id>xpresso</Id><BaseIcon width=\"16\" " +
		      "height=\"16\"><![CDATA[http://developer.yahoo.com/maps/star_blue.gif]]></BaseIcon>" +
		      "</Group></ymaps:Groups>");
		
		ReportResultSet rrs = report.getReportResultSet();
		while(rrs.nextRow()){
			xml.append("<item>");
			for (int i =0; i < rrs.getNumberOfColumns(); i++){
				xml.append("<" + rrs.getHeaderText(i) + ">");
				xml.append("<![CDATA[");
				xml.append(rrs.getRowValue(i));
				xml.append("]]>");
				xml.append("</" + rrs.getHeaderText(i) + ">");
			}
			xml.append("</item>");
		}
		xml.append("</channel></rss>");
		return xml.toString();
	}

	
	
	
}
